package ar.diegodob.charcas.ui.modules.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;

public class ControlPanelModule implements EntryPoint {

	public void onModuleLoad() {

		Button startButton = new Button("Play", new ClickListener() {
			public void onClick(Widget sender) {
				// (2) Create an asynchronous callback to handle the result.
				//
				AsyncCallback callback = new AsyncCallback() {
					public void onSuccess(Object result) {
						Window.alert("OK!");
					}

					public void onFailure(Throwable caught) {
						Window.alert("RPC to play() failed.");
					}

				};

				PlayerServiceAsync playerService = (PlayerServiceAsync) GWT
						.create(PlayerService.class);
				playerService.play("D:/Musica/salsa adriana/01 Pista 1.mp3",
						callback);

			}
		});
		Button stopButton = new Button("Stop", new ClickListener() {
			public void onClick(Widget sender) {
				// (2) Create an asynchronous callback to handle the result.
				//
				AsyncCallback callback = new AsyncCallback() {
					public void onSuccess(Object result) {
						Window.alert("OK!");
					}

					public void onFailure(Throwable caught) {
						Window.alert("RPC to stop() failed.");
					}

				};

				PlayerServiceAsync playerService = (PlayerServiceAsync) GWT
						.create(PlayerService.class);
				playerService.stop(callback);

			}
		});
		
		RootPanel.get().add(startButton);
		RootPanel.get().add(stopButton);
	}
}
